﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Collections;
using SAC.Helper;
using DAL;
namespace BLL
{
    public class BLLRep
    {
        static string xzTime = "2012-1-1";     //取值限制时间
        static string toExcel = "yse";         //导出Excel是否控制小数点
        string rtDBType = "";   //实时数据库
        string rlDBType = "";   //关系数据库

        DALRep dr = new DALRep();
        DALReport drp = new DALReport();
        ArrayList list = new ArrayList();
        StringBuilder sb = new StringBuilder();
        StrHelper sh = new StrHelper();
        DALUtilityMehtod um = new DALUtilityMehtod();

        /// <summary>
        /// 构造函数
        /// </summary>
        static BLLRep()
        {

            ///br.rtDBType = IniHelper.ReadIniData("RelationDBbase", "DBType", null);
        }

        /// <summary>
        /// 初始化函数
        /// </summary>
        private void init()
        {
            if (IniHelper.ReadIniData("Report", "XZTime", null) != "")
                xzTime = IniHelper.ReadIniData("Report", "XZTime", null);

            if (IniHelper.ReadIniData("Report", "Excle", null) != "")
                toExcel = IniHelper.ReadIniData("Report", "Excle", null);
        }

        /// <summary>
        /// 值报
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <param name="unit"></param>
        /// <param name="repType"></param>
        /// <returns></returns>
        public string RetTableByVal(string repName, string date, int unit, string repType)
        {
            string[] arr;
            string[] arrBZ = null;
            string[] tjxsBZ = null;

            string qsrq = "";
            string jsrq = "";
            string bzID = "";
            string bName = "";
            string bzTime = "";

            DateTime dtNow = DateTime.Now;

            this.init();

            if (Convert.ToDateTime(date) > dtNow || Convert.ToDateTime(date) < Convert.ToDateTime(xzTime))
            { sb.Append("请选择正确日期进行查询......"); return sb.ToString(); }

            DataTable dtXZ = dr.RetTableXZ(unit.ToString(), repName);

            if (repType == "日值")
            {
                bName = "统计数据值日表";

                date = DateTime.Parse(date).ToString("yyyy-MM-dd 0:00:00");

                list = drp.RetArrsRepVal(repName, date, bName, out bzID, out bzTime);

                if (bzTime.Contains(';'))
                {
                    string bz = bzTime.TrimEnd(';');

                    string[] bzsj = bz.Split(';');

                    tjxsBZ = new string[bzsj.Length];

                    for (int i = 0; i < bzsj.Length; i++)
                    {
                        string[] sj = bzsj[i].Split(',');

                        qsrq = sj[0].ToString();
                        jsrq = sj[1].ToString();

                        tjxsBZ[i] = um.tjxs(qsrq, jsrq, unit);
                    }
                }
            }
            else if (repType == "月值")
            {
                bName = "统计数据值月表";
            }
            else if (repType == "年值")
            {
                bName = "统计数据值年表";
            }
            else if (repType == "季值")
            {
                bName = "统计数据值季表";
            }

            string[] zb = (string[])list[0];
            string[] un = (string[])list[1];
            string[] lay = (string[])list[2];
            string[] dv = (string[])list[3];
            string[] dvExcel = (string[])list[4];

            if (list.Count > 0)
            {
                if (bzID.Contains(';'))
                {
                    string bz = bzID.TrimEnd(';');

                    arrBZ = bz.Split(';');
                }

                if (toExcel == "yes")
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\">");
                else
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\">");

                sb.Append(" <tr style='width: 80%;' bgcolor='#CFE6FC'>");

                sb.Append("<td style='width: 20%;'> <div align='center'> 指 标 名 称 </td>");

                sb.Append("<td style='width: 10%;'> <div align='center'> 单 位 </td>");

                sb.Append("<td style='width: 10%;'><div align='center'> 设计值 </td>");

                for (int i = 0; i < arrBZ.Length; i++)
                { sb.AppendFormat("<td style='width: 10%;'><div align='center'>{0}</td>", sh.ConvertChinese(arrBZ[i].TrimEnd())); }

                sb.Append(" </tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dv[i] != null)
                    {
                        string[] arr1 = dv[i].ToString().Split(';');
                        //#2
                        string str = arr1[1].ToString();

                        string[] arrBZ1 = str.Split(',');

                        for (int j = 0; j < arrBZ1.Length; j++)
                        {
                            string[] arrValue = arrBZ1[j].ToString().Split('+');

                            sb.AppendFormat("<td align='center'>{0}</td>", arrValue[1]);
                        }
                    }
                    ////累计类型和电量类型不做判断
                    //if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    //{
                    //    if (dv[i] != null)
                    //    {
                    //        arr = dv[i].Split(',');

                    //        if (arrBZ.Length > (arr.Length - 1) || arrBZ.Length == (arr.Length - 1))
                    //        {
                    //            int a = arrBZ.Length - (arr.Length - 1);

                    //            for (int j = 0; j < arr.Length - 1; j++)
                    //                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());

                    //            for (int j = 0; j < a; j++)
                    //                sb.AppendFormat("<td align='center'>0</td>");
                    //        }
                    //    }
                    //}
                    //else
                    //{
                    //    if (repName == "厂用电报表")
                    //    {
                    //        if (dv[i] != null)
                    //        {
                    //            arr = dv[i].Split(',');

                    //            if (arrBZ.Length > (arr.Length - 1) || arrBZ.Length == (arr.Length - 1))
                    //            {
                    //                int a = arrBZ.Length - (arr.Length - 1);

                    //                for (int j = 0; j < arr.Length - 1; j++)
                    //                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());

                    //                for (int j = 0; j < a; j++)
                    //                    sb.AppendFormat("<td align='center'>0</td>");
                    //            }
                    //        }
                    //    }
                    //    else if (repName == "汽机报表" || repName == "锅炉报表")
                    //    {
                    //        if (dv[i] != null)
                    //        {
                    //            arr = dv[i].Split(',');

                    //            if (arrBZ.Length > (arr.Length - 1) || arrBZ.Length == (arr.Length - 1))
                    //            {
                    //                int a = arrBZ.Length - (arr.Length - 1);

                    //                for (int j = 0; j < arr.Length - 1; j++)
                    //                {
                    //                    if (tjxsBZ[j] != "0")
                    //                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                    //                    else
                    //                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                    //                }

                    //                for (int j = 0; j < a; j++)
                    //                {
                    //                    sb.AppendFormat("<td align='center'>0</td>");
                    //                }
                    //            }
                    //        }
                    //    }
                    //    else
                    //    {
                    //        if (dv[i] != null)
                    //        {
                    //            arr = dv[i].Split(',');

                    //            if (arrBZ.Length > (arr.Length - 1) || arrBZ.Length == (arr.Length - 1))
                    //            {
                    //                int a = arrBZ.Length - (arr.Length - 1);

                    //                if (i <= 10)
                    //                {
                    //                    for (int j = 0; j < arr.Length - 1; j++)
                    //                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());

                    //                    for (int j = 0; j < a; j++)
                    //                        sb.AppendFormat("<td align='center'>0</td>");
                    //                }
                    //                else
                    //                {
                    //                    for (int j = 0; j < arr.Length - 1; j++)
                    //                    {
                    //                        if (tjxsBZ[j] != "0")
                    //                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                    //                        else
                    //                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                    //                    }

                    //                    for (int j = 0; j < a; j++)
                    //                    {
                    //                        sb.AppendFormat("<td align='center'>0</td>");
                    //                    }
                    //                }
                    //            }
                    //        }
                    //    }
                    //}
                }
                sb.Append("</table>");

                #region 导出Excel表
                if (toExcel == "no")
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\" style=\"display:none;\">");
                else
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\" style=\"display:none;\">");

                sb.Append(" <tr style='width: 80%;' bgcolor='#CFE6FC'>");

                sb.Append("<td style='width: 20%;'> <div align='center'> 指 标 名 称 </td>");

                sb.Append("<td style='width: 10%;'> <div align='center'> 单 位 </td>");

                sb.Append("<td style='width: 10%;'><div align='center'> 设计值 </td>");

                for (int i = 0; i < arrBZ.Length; i++)
                { sb.AppendFormat("<td style='width: 10%;'><div align='center'>{0}</td>", sh.ConvertChinese(arrBZ[i].TrimEnd())); }

                sb.Append(" </tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    //累计类型和电量类型不做判断
                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dvExcel[i] != null)
                        {
                            arr = dvExcel[i].Split(',');

                            if (arrBZ.Length > (arr.Length - 1) || arrBZ.Length == (arr.Length - 1))
                            {
                                int a = arrBZ.Length - (arr.Length - 1);

                                for (int j = 0; j < arr.Length - 1; j++)
                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());

                                for (int j = 0; j < a; j++)
                                    sb.AppendFormat("<td align='center'>0</td>");
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                arr = dvExcel[i].Split(',');

                                if (arrBZ.Length > (arr.Length - 1) || arrBZ.Length == (arr.Length - 1))
                                {
                                    int a = arrBZ.Length - (arr.Length - 1);

                                    for (int j = 0; j < arr.Length - 1; j++)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());

                                    for (int j = 0; j < a; j++)
                                        sb.AppendFormat("<td align='center'>0</td>");
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                arr = dvExcel[i].Split(',');

                                if (arrBZ.Length > (arr.Length - 1) || arrBZ.Length == (arr.Length - 1))
                                {
                                    int a = arrBZ.Length - (arr.Length - 1);

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (tjxsBZ[j] != "0")
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                    }

                                    for (int j = 0; j < a; j++)
                                    {
                                        sb.AppendFormat("<td align='center'>0</td>");
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dvExcel[i] != null)
                            {
                                arr = dvExcel[i].Split(',');

                                if (arrBZ.Length > (arr.Length - 1) || arrBZ.Length == (arr.Length - 1))
                                {
                                    int a = arrBZ.Length - (arr.Length - 1);

                                    if (i <= 10)
                                    {
                                        for (int j = 0; j < arr.Length - 1; j++)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());

                                        for (int j = 0; j < a; j++)
                                            sb.AppendFormat("<td align='center'>0</td>");
                                    }
                                    else
                                    {
                                        for (int j = 0; j < arr.Length - 1; j++)
                                        {
                                            if (tjxsBZ[j] != "0")
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                        }

                                        for (int j = 0; j < a; j++)
                                        {
                                            sb.AppendFormat("<td align='center'>0</td>");
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                sb.Append("</table>");

                #endregion
            }
            return sb.ToString();
        }

        /// <summary>
        /// 日报(机组轮转)
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetTableByDay(string repName, string repType, DateTime date)
        {
            string[] arr;
            string qsrq;
            string jsrq;
            string tjxsA;
            string tjxsB;

            bool isTure = false;

            DateTime dtNow = DateTime.Now;

            this.init();

            if (date < dtNow && date >= Convert.ToDateTime(xzTime))
            {
                if (dtNow.Year == date.Year && dtNow.Month == date.Month && dtNow.Day == date.Day)
                {
                    qsrq = date.ToString("yyyy-MM-dd 00:00:00");
                    jsrq = dtNow.AddHours(-1).ToString("yyyy-MM-dd H:00:00");
                    isTure = true;
                }
                else
                {
                    qsrq = date.ToString("yyyy-MM-dd H:mm:ss");
                    jsrq = date.AddDays(+1).ToString("yyyy-MM-dd H:mm:ss");
                }
            }
            else
            { sb.Append("请输入正确的日期进行查询......"); return sb.ToString(); }

            if (repType == "日报")
            { repType = "日点"; }

            tjxsA = um.tjxs(qsrq, jsrq, 1);
            tjxsB = um.tjxs(qsrq, jsrq, 2);

            //list = dr.RetArrsRepDay(repName, repType, qsrq, jsrq, isTure);

            list = drp.RetArrsRepDay(repName, repType, qsrq, jsrq, isTure);

            DataTable dtXZ = dr.RetTableXZ("1", repName);

            string[] zb = (string[])list[0];
            string[] un = (string[])list[1];
            string[] lay = (string[])list[2];
            string[] dv = (string[])list[3];
            string[] dvExcel = (string[])list[4];

            if (list.Count > 0)
            {
                if (toExcel == "yes")
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\">");
                else
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\">");

                sb.Append("<tr style=\"width: 80%;\" bgcolor=\"#CFE6FC\"> ");
                sb.Append("<td style=\"width: 20%;\"><div align=\"center\">指 标 名 称</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">单 位</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">设计值</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">#1机</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">#2机</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">全厂</td>");
                sb.Append("</tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dv[i] != null)
                        {
                            if (dv[i].TrimEnd(',').Contains(','))
                            {
                                arr = dv[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (zb[i] == "输煤单耗" || zb[i] == "输煤设备电率")
                                        { sb.AppendFormat("<td align='center'>{0}</td>", "0"); }
                                        else
                                        {
                                            if (arr[j] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (j == 0)
                                            {
                                                if (tjxsA == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else if (j == 1)
                                            {
                                                if (tjxsB == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }

                sb.Append("</table>");

                #region 导出Excel表
                if (toExcel == "no")
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\" style=\"display:none;\">");
                else
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\" style=\"display:none;\">");

                sb.Append("<tr style=\"width: 80%;\" bgcolor=\"#CFE6FC\"> ");
                sb.Append("<td style=\"width: 20%;\"><div align=\"center\">指 标 名 称</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">单 位</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">设计值</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">#1机</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">#2机</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">全厂</td>");
                sb.Append("</tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dvExcel[i] != null)
                        {
                            if (dvExcel[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvExcel[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (j == 0)
                                            {
                                                if (tjxsA == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else if (j == 1)
                                            {
                                                if (tjxsB == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }

                sb.Append("</table>");
                #endregion
            }
            else
            { sb.Append("没有查询到结果..."); return sb.ToString(); }

            return sb.ToString();
        }

        /// <summary>
        /// 日报(机组轮转)
        /// 任意时间段数据查询
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetTableByDay(string repName, string repType, string qsrq, string jsrq)
        {
            string[] arr;
            string tjxsA;
            string tjxsB;

            bool isTure = false;

            DateTime dtNow = DateTime.Now;

            this.init();

            if (DateTime.Parse(jsrq) > dtNow)
                jsrq = dtNow.AddHours(-1).ToString("yyyy-MM-dd H:00:00");

            if (DateTime.Parse(qsrq) > DateTime.Parse(jsrq) || DateTime.Parse(qsrq) == DateTime.Parse(jsrq))
            { sb.Append("请输入正确的日期进行查询......"); return sb.ToString(); }

            if (repType == "日报")
            { repType = "日点"; }

            tjxsA = um.tjxs(qsrq, jsrq, 1);
            tjxsB = um.tjxs(qsrq, jsrq, 2);

            //list = dr.RetArrsRepDay(repName, repType, qsrq, jsrq, isTure);

            list = drp.RetArrsRepDay(repName, repType, qsrq, jsrq, isTure);

            DataTable dtXZ = dr.RetTableXZ("1", repName);

            string[] zb = (string[])list[0];
            string[] un = (string[])list[1];
            string[] lay = (string[])list[2];
            string[] dv = (string[])list[3];
            string[] dvExcel = (string[])list[4];

            if (list.Count > 0)
            {
                if (toExcel == "yes")
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\">");
                else
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\">");

                sb.Append("<tr style=\"width: 80%;\" bgcolor=\"#CFE6FC\"> ");
                sb.Append("<td style=\"width: 20%;\"><div align=\"center\">指 标 名 称</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">单 位</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">设计值</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">#1机</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">#2机</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">全厂</td>");
                sb.Append("</tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dv[i] != null)
                        {
                            if (dv[i].TrimEnd(',').Contains(','))
                            {
                                arr = dv[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (zb[i] == "输煤单耗" || zb[i] == "输煤设备电率")
                                        { sb.AppendFormat("<td align='center'>{0}</td>", "0"); }
                                        else
                                        {
                                            if (arr[j] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (j == 0)
                                            {
                                                if (tjxsA == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else if (j == 1)
                                            {
                                                if (tjxsB == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }

                sb.Append("</table>");

                #region 导出Excel表
                if (toExcel == "no")
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\" style=\"display:none;\">");
                else
                    sb.Append("<table width=\"90%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\" style=\"display:none;\">");

                sb.Append("<tr style=\"width: 80%;\" bgcolor=\"#CFE6FC\"> ");
                sb.Append("<td style=\"width: 20%;\"><div align=\"center\">指 标 名 称</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">单 位</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">设计值</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">#1机</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">#2机</td>");
                sb.Append("<td style=\"width: 10%;\"><div align=\"center\">全厂</td>");
                sb.Append("</tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dvExcel[i] != null)
                        {
                            if (dvExcel[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvExcel[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (j == 0)
                                            {
                                                if (tjxsA == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else if (j == 1)
                                            {
                                                if (tjxsB == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }

                sb.Append("</table>");
                #endregion
            }
            else
            { sb.Append("没有查询到结果..."); return sb.ToString(); }

            return sb.ToString();
        }

        /// <summary>
        /// 月报/年报(机组轮转)
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="repType"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetTableByMonth(string repName, string repType, DateTime date)
        {
            bool isTure = false;

            string[] arr;
            string pType = "";
            string qsrqB = "";
            string jsrqB = "";
            string qsrqT = "";
            string jsrqT = "";

            string tjxsA = "";
            string tjxsB = "";
            string tjxsTA = "";
            string tjxsTB = "";

            DateTime ndate = DateTime.Now.Date;

            if (date < Convert.ToDateTime(xzTime) || date > ndate)
            { sb.Append("请输入正确日期查询"); return sb.ToString(); }

            if (repType == "月报")
            {
                pType = "月点";

                if (date.Year == ndate.Year && date.Month == ndate.Month)
                {
                    qsrqB = date.ToString("yyyy-MM-dd H:mm:ss");
                    //jsrqB = DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd H:00:00");
                    jsrqB = DateTime.Now.ToString("yyyy-MM-dd 0:00:00");

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(qsrqB).AddYears(-1).AddMonths(+1).ToString("yyyy-MM-dd H:mm:ss");

                    isTure = true;
                }
                else
                {
                    qsrqB = date.ToString("yyyy-MM-dd H:mm:ss");
                    jsrqB = sh.LastDayOfMonth(DateTime.Parse(qsrqB)).AddDays(+1).ToString("yyyy-MM-dd H:mm:ss");

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(jsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                }
            }
            else if (repType == "年报")
            {
                pType = "年点";

                if (date.Year == ndate.Year)
                {
                    qsrqB = date.ToString("yyyy-MM-dd H:mm:ss");
                    //jsrqB = DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd H:00:00");
                    jsrqB = DateTime.Now.ToString("yyyy-MM-dd 0:00:00");

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = qsrqB;

                    isTure = true;
                }
                else
                {
                    qsrqB = date.ToString("yyyy-MM-dd H:mm:ss");
                    jsrqB = DateTime.Parse(qsrqB).AddYears(+1).ToString("yyyy-MM-dd H:mm:ss");

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = qsrqB;
                }
            }

            tjxsA = um.tjxs(qsrqB, jsrqB, 1);
            tjxsB = um.tjxs(qsrqB, jsrqB, 2);
            tjxsTA = um.tjxs(qsrqT, jsrqT, 1);
            tjxsTB = um.tjxs(qsrqT, jsrqT, 2);

            DataTable dtXZ = dr.RetTableXZ("1", repName);

            //list = dr.RetArrsRepMonth(repName, repType, pType, qsrqB, jsrqB, qsrqT, jsrqT, isTure);

            list = drp.RetArrsRepMonth(repName, repType, pType, qsrqB, jsrqB, qsrqT, jsrqT, isTure);

            string[] zb = (string[])list[0];
            string[] un = (string[])list[1];
            string[] lay = (string[])list[2];
            string[] dv = (string[])list[3];
            string[] dvT = (string[])list[4];
            string[] dvExcel = (string[])list[5];
            string[] dvExcelT = (string[])list[6];

            if (list.Count > 0)
            {
                sb.Append("<table width=\"98%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\">");
                sb.Append("<tr bgcolor=\"#CFE6FC\"> <td rowspan=\"2\" align=\"center\"> 指 标 名 称  </td>");
                sb.Append("<td rowspan=\"2\" align=\"center\">单 位</td>");
                sb.Append("<td rowspan=\"2\" align=\"center\">设 计 值</td>");
                sb.Append("<td colspan=\"3\" align=\"center\">本 期</td>");
                sb.Append("<td colspan=\"3\" align=\"center\">同 期</td></tr>");
                sb.Append("<tr bgcolor=\"#CFE6FC\"><td align=\"center\">#1机</td>");
                sb.Append("<td align=\"center\">#2机</td>");
                sb.Append("<td align=\"center\">全厂</td>");
                sb.Append("<td align=\"center\">#1机</td>");
                sb.Append("<td align=\"center\">#2机</td>");
                sb.Append("<td align=\"center\">全厂</td></tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dv[i] != null)
                        {
                            if (dv[i].TrimEnd(',').Contains(','))
                            {
                                arr = dv[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }

                        if (dvT[i] != null)
                        {
                            if (dvT[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvT[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {

                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvT[i] != null)
                            {
                                if (dvT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (j == 0)
                                            {
                                                if (tjxsA == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else if (j == 1)
                                            {
                                                if (tjxsB == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvT[i] != null)
                            {
                                if (dvT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsTA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsTB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvT[i] != null)
                            {
                                if (dvT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (i <= 10)
                                                { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                                else
                                                {
                                                    if (j == 0)
                                                    {
                                                        if (tjxsTA == "0")
                                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                        else
                                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                    }
                                                    else if (j == 1)
                                                    {
                                                        if (tjxsTB == "0")
                                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                        else
                                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                    }
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }

                sb.Append("</table>");

                #region 导出 Excel 表

                sb.Append("<table width=\"98%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\" style=\"display:none;\" >");
                sb.Append("<tr bgcolor=\"#CFE6FC\"> <td rowspan=\"2\" align=\"center\"> 指 标 名 称  </td>");
                sb.Append("<td rowspan=\"2\" align=\"center\">单 位</td>");
                sb.Append("<td rowspan=\"2\" align=\"center\">设 计 值</td>");
                sb.Append("<td colspan=\"3\" align=\"center\">本 期</td>");
                sb.Append("<td colspan=\"3\" align=\"center\">同 期</td></tr>");
                sb.Append("<tr bgcolor=\"#CFE6FC\"><td align=\"center\">#1机</td>");
                sb.Append("<td align=\"center\">#2机</td>");
                sb.Append("<td align=\"center\">全厂</td>");
                sb.Append("<td align=\"center\">#1机</td>");
                sb.Append("<td align=\"center\">#2机</td>");
                sb.Append("<td align=\"center\">全厂</td></tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dvExcel[i] != null)
                        {
                            if (dvExcel[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvExcel[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }

                        if (dvExcelT[i] != null)
                        {
                            if (dvExcelT[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvExcelT[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {

                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvExcelT[i] != null)
                            {
                                if (dvExcelT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcelT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (j == 0)
                                            {
                                                if (tjxsA == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else if (j == 1)
                                            {
                                                if (tjxsB == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvExcelT[i] != null)
                            {
                                if (dvExcelT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcelT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsTA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsTB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvExcelT[i] != null)
                            {
                                if (dvExcelT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcelT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (i <= 10)
                                                { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                                else
                                                {
                                                    if (j == 0)
                                                    {
                                                        if (tjxsTA == "0")
                                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                        else
                                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                    }
                                                    else if (j == 1)
                                                    {
                                                        if (tjxsTB == "0")
                                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                        else
                                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                    }
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }

                sb.Append("</table>");

                #endregion
            }
            else
            { sb.Append("没有查询到结果..."); return sb.ToString(); }

            return sb.ToString();
        }

        /// <summary>
        /// 季报(机组轮转)
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="repType"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetTableByMonth(string repName, string repType, DateTime date, int jd)
        {
            bool isTure = false;

            string[] arr;
            string pType = "";
            string errMsg = "";
            string qsrqB = "";
            string jsrqB = "";
            string qsrqT = "";
            string jsrqT = "";

            string tjxsA = "";
            string tjxsB = "";
            string tjxsTA = "";
            string tjxsTB = "";

            DateTime ndate = DateTime.Now.Date;

            this.init();

            if (repType == "季报")
            {
                pType = "季点";
            }
            string res = this.IsQuarTerly(date, jd, out isTure, out errMsg);

            if (errMsg == "")
            {
                if (res.Contains(';'))
                {
                    string[] str = res.Split(';');

                    qsrqB = str[0];
                    jsrqB = str[1];
                    qsrqT = str[2];
                    jsrqT = str[3];
                }
            }
            else
            { sb.Append(errMsg); return sb.ToString(); }

            if (Convert.ToDateTime(qsrqB) < Convert.ToDateTime(xzTime))
            { sb.Append("请选择正确时间进行查询..."); return sb.ToString(); }

            tjxsA = um.tjxs(qsrqB, jsrqB, 1);
            tjxsB = um.tjxs(qsrqB, jsrqB, 2);
            tjxsTA = um.tjxs(qsrqT, jsrqT, 1);
            tjxsTB = um.tjxs(qsrqT, jsrqT, 2);

            DataTable dtXZ = dr.RetTableXZ("1", repName);

            list = drp.RetArrsRepMonth(repName, repType, pType, qsrqB, jsrqB, qsrqT, jsrqT, isTure);

            string[] zb = (string[])list[0];
            string[] un = (string[])list[1];
            string[] lay = (string[])list[2];
            string[] dv = (string[])list[3];
            string[] dvT = (string[])list[4];
            string[] dvExcel = (string[])list[5];
            string[] dvExcelT = (string[])list[6];

            if (list.Count > 0)
            {
                if (toExcel == "yes")
                    sb.Append("<table width=\"98%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\">");
                else
                    sb.Append("<table width=\"98%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\">");

                sb.Append("<tr bgcolor=\"#CFE6FC\"> <td rowspan=\"2\" align=\"center\"> 指 标 名 称  </td>");
                sb.Append("<td rowspan=\"2\" align=\"center\">单 位</td>");
                sb.Append("<td rowspan=\"2\" align=\"center\">设 计 值</td>");
                sb.Append("<td colspan=\"3\" align=\"center\">本 期</td>");
                sb.Append("<td colspan=\"3\" align=\"center\">同 期</td></tr>");
                sb.Append("<tr bgcolor=\"#CFE6FC\"><td align=\"center\">#1机</td>");
                sb.Append("<td align=\"center\">#2机</td>");
                sb.Append("<td align=\"center\">全厂</td>");
                sb.Append("<td align=\"center\">#1机</td>");
                sb.Append("<td align=\"center\">#2机</td>");
                sb.Append("<td align=\"center\">全厂</td></tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dv[i] != null)
                        {
                            if (dv[i].TrimEnd(',').Contains(','))
                            {
                                arr = dv[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }

                        if (dvT[i] != null)
                        {
                            if (dvT[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvT[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {

                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvT[i] != null)
                            {
                                if (dvT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (j == 0)
                                            {
                                                if (tjxsA == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else if (j == 1)
                                            {
                                                if (tjxsB == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvT[i] != null)
                            {
                                if (dvT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsTA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsTB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvT[i] != null)
                            {
                                if (dvT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (i <= 10)
                                                { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                                else
                                                {
                                                    if (j == 0)
                                                    {
                                                        if (tjxsTA == "0")
                                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                        else
                                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                    }
                                                    else if (j == 1)
                                                    {
                                                        if (tjxsTB == "0")
                                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                        else
                                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                    }
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }

                sb.Append("</table>");

                #region 导出 Excel 表

                if (toExcel == "no")
                    sb.Append("<table width=\"98%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\" style=\"display:none;\" >");
                else
                    sb.Append("<table width=\"98%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\" style=\"display:none;\" >");


                sb.Append("<tr bgcolor=\"#CFE6FC\"> <td rowspan=\"2\" align=\"center\"> 指 标 名 称  </td>");
                sb.Append("<td rowspan=\"2\" align=\"center\">单 位</td>");
                sb.Append("<td rowspan=\"2\" align=\"center\">设 计 值</td>");
                sb.Append("<td colspan=\"3\" align=\"center\">本 期</td>");
                sb.Append("<td colspan=\"3\" align=\"center\">同 期</td></tr>");
                sb.Append("<tr bgcolor=\"#CFE6FC\"><td align=\"center\">#1机</td>");
                sb.Append("<td align=\"center\">#2机</td>");
                sb.Append("<td align=\"center\">全厂</td>");
                sb.Append("<td align=\"center\">#1机</td>");
                sb.Append("<td align=\"center\">#2机</td>");
                sb.Append("<td align=\"center\">全厂</td></tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dvExcel[i] != null)
                        {
                            if (dvExcel[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvExcel[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }

                        if (dvExcelT[i] != null)
                        {
                            if (dvExcelT[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvExcelT[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {

                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvExcelT[i] != null)
                            {
                                if (dvExcelT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcelT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (j == 0)
                                            {
                                                if (tjxsA == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else if (j == 1)
                                            {
                                                if (tjxsB == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvExcelT[i] != null)
                            {
                                if (dvExcelT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcelT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsTA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsTB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsA == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsB == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }

                            if (dvExcelT[i] != null)
                            {
                                if (dvExcelT[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcelT[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (Convert.ToDateTime(qsrqT) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (i <= 10)
                                                { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                                else
                                                {
                                                    if (j == 0)
                                                    {
                                                        if (tjxsTA == "0")
                                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                        else
                                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                    }
                                                    else if (j == 1)
                                                    {
                                                        if (tjxsTB == "0")
                                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                        else
                                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                    }
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }

                sb.Append("</table>");

                #endregion
            }
            else
            { sb.Append("没有查询到结果..."); return sb.ToString(); }

            return sb.ToString();
        }

        /// <summary>
        /// 月明细
        /// (机组轮转)
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="unit"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetTableByMonthInfo(string repName, int unit, DateTime date)
        {
            int isDay;
            string fDay;
            string lDay;
            string[] arr;
            string[] qsrq;
            string[] jsrq;
            string[] tjxs;

            DateTime ndate = DateTime.Now.Date;

            this.init();

            if (date < DateTime.Parse(xzTime))
            {
                sb.Append("对不起,请选择其他日期查询...");
                return sb.ToString();
            }

            if (date.Year == ndate.Year && date.Month == ndate.Month && ndate.Day == 1)
            {
                sb.Append("对不起,请选择其他日期查询...");
                return sb.ToString();
            }

            if (date.Year == ndate.Year && date.Month == ndate.Month)
                isDay = 0;
            else
                isDay = 1;

            #region 日期&统计小时

            int days = DateTime.DaysInMonth(date.Year, date.Month);

            qsrq = new string[days + 1];
            jsrq = new string[days + 1];
            tjxs = new string[days + 1];

            #region 日期
            if (isDay == 0)
            {
                for (int i = 1; i < DateTime.Now.Day; i++)
                {
                    qsrq[i] = date.Year + "-" + date.Month + "-" + i + " 00:00:00";
                    jsrq[i] = DateTime.Parse(date.Year + "-" + date.Month + "-" + i + " 00:00:00").AddDays(1).ToString();
                }
                fDay = qsrq[1];
                lDay = DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd H:00:00");
            }
            else
            {
                for (int i = 1; i < days + 1; i++)
                {
                    qsrq[i] = date.Year + "-" + date.Month + "-" + i + " 00:00:00";
                    jsrq[i] = DateTime.Parse(date.Year + "-" + date.Month + "-" + i + " 00:00:00").AddDays(1).ToString();
                }
                fDay = qsrq[1];
                lDay = jsrq[days];
            }

            #endregion

            for (int i = 1; i < qsrq.Length; i++)
            {
                if (qsrq[i] != null)
                    tjxs[i - 1] = um.tjxs(qsrq[i], jsrq[i], unit);
                else
                    tjxs[i - 1] = "0";
            }

            tjxs[days] = um.tjxs(fDay, lDay, unit); ;
            #endregion

            list = drp.RetArrsRepMonthInfo(repName, unit, date, isDay);

            DataTable dtXZ = dr.RetTableXZ(unit.ToString(), repName);

            string[] zb = (string[])list[0];
            string[] un = (string[])list[1];
            string[] lay = (string[])list[2];
            string[] dv = (string[])list[3];
            string[] dvExcel = (string[])list[4];

            if (list.Count > 0)
            {
                if (toExcel == "yes")
                    sb.Append("<table border=\"1\" width='2470px;' valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\">");
                else
                    sb.Append("<table border=\"1\" width='2470px;' valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\">");

                sb.Append("<tr bgcolor=\"#CFE6FC\">");
                sb.Append("<td style=\"width: 220px;\"><div align=\"center\">指 标 名 称</td>");
                sb.Append("<td style=\"width: 65px;\"><div align=\"center\">单 位 </td>");
                sb.Append("<td style=\"width: 90px;\"><div align=\"center\">设 计 值</td>");

                for (int i = 1; i <= days; i++)
                {
                    sb.AppendFormat("<td style=\"width: 65px;\"><div align=\"center\">{0}</td>", i);
                }

                sb.Append("<td style=\"width: 80px;\"><div align=\"center\">月度累计</td></tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dv[i] != null)
                        {
                            if (dv[i].TrimEnd(',').Contains(','))
                            {
                                arr = dv[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            //if (zb[i] == "输煤单耗" || zb[i] == "输煤设备电率")
                            //{
                            //    if (dv[i] != null)
                            //    {
                            //        if (dv[i].TrimEnd(',').Contains(','))
                            //        {
                            //            arr = dv[i].Split(',');

                            //            for (int j = 0; j < arr.Length - 1; j++)
                            //            {
                            //                if (j == arr.Length - 1)
                            //                {
                            //                    if (arr[j] != null)
                            //                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                            //                    else
                            //                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                            //                }
                            //                else
                            //                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                            //            }
                            //        }
                            //    }
                            //}
                            //else
                            //{
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                            // }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (tjxs[j] == "0")
                                                sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (tjxs[j] == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }
                sb.Append("</table>");

                #region 导出Excel表
                if (toExcel == "no")
                    sb.Append("<table border=\"1\" width='2470px;' valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\"  style=\"display:none;\" id=\"CX\">");
                else
                    sb.Append("<table border=\"1\" width='2470px;' valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\"  style=\"display:none;\" id=\"CX1\">");

                sb.Append("<tr bgcolor=\"#CFE6FC\">");
                sb.Append("<td style=\"width: 220px;\"><div align=\"center\">指 标 名 称</td>");
                sb.Append("<td style=\"width: 65px;\"><div align=\"center\">单 位 </td>");
                sb.Append("<td style=\"width: 90px;\"><div align=\"center\">设 计 值</td>");

                for (int i = 1; i <= days; i++)
                {
                    sb.AppendFormat("<td style=\"width: 65px;\"><div align=\"center\">{0}</td>", i);
                }

                sb.Append("<td style=\"width: 80px;\"><div align=\"center\">月度累计</td></tr>");

                for (int i = 1; i < zb.Length; i++)
                {
                    sb.Append("<tr>");

                    sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                    sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dvExcel[i] != null)
                        {
                            if (dvExcel[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvExcel[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (tjxs[j] == "0")
                                                sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dvExcel[i] != null)
                            {
                                if (dvExcel[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dvExcel[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                            else
                                            {
                                                if (tjxs[j] == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                }
                            }
                        }
                        sb.Append("</tr>");
                    }
                }
                sb.Append("</table>");

                #endregion
            }
            else
            { sb.Append("没有查询到结果..."); return sb.ToString(); }



            return sb.ToString();
        }

        /// <summary>
        /// 年明细
        /// (机组轮转)
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="unit"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public string RetTableByYearInfo(string repName, int unit, DateTime date)
        {
            int isDay;
            string sDate = "";
            string[] arr;
            string[] qsrq = new string[12];
            string[] jsrq = new string[12];
            string[] qsrqT = new string[12];
            string[] jsrqT = new string[12];
            string[] tjxs = new string[14];

            ArrayList list = new ArrayList();

            DateTime ndate = DateTime.Now.Date;

            this.init();

            if (date < DateTime.Parse(xzTime))
            {
                sb.Append("对不起,请选择其他日期查询...");
                return sb.ToString();
            }

            if (date.Year == ndate.Year && ndate.Month == 1)
            {
                sb.AppendFormat("<td colspan=\"19\"  align='center'>{0}</td>", "对不起,请选择其他日期查询...");
                return sb.ToString();
            }

            if (date.Year <= ndate.Year)
            {
                if (date.Year == ndate.Year)
                    isDay = 0;
                else
                    isDay = 1;

                #region 日期
                //本期时间
                if (isDay == 0)
                {
                    for (int i = 0; i < DateTime.Now.Month; i++)
                    {
                        qsrq[i] = date.AddMonths(+i).ToString("yyyy-MM-dd H:mm:ss");
                        jsrq[i] = date.AddMonths(+i).AddMonths(+1).ToString("yyyy-MM-dd H:mm:ss");

                        if (DateTime.Parse(qsrq[i]).Month == DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 0:00:00")).Month)
                            jsrq[i] = DateTime.Now.ToString("yyyy-MM-dd 0:00:00");//DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd")

                        sDate = jsrq[i];
                    }
                }
                else
                {
                    for (int i = 0; i < 12; i++)
                    {
                        qsrq[i] = date.AddMonths(+i).ToString("yyyy-MM-dd H:mm:ss");
                        jsrq[i] = date.AddMonths(+i).AddMonths(+1).ToString("yyyy-MM-dd H:mm:ss");
                        sDate = jsrq[i];
                    }
                }

                DateTime dtT = DateTime.Parse(qsrq[0]).AddYears(-1);

                //同期时间
                for (int i = 0; i < 12; i++)
                {
                    qsrqT[i] = dtT.AddMonths(i).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT[i] = dtT.AddMonths(i).AddMonths(+1).ToString("yyyy-MM-dd H:mm:ss");
                }

                for (int i = 0; i < qsrq.Length; i++)
                {
                    if (qsrq[i] != null)
                        tjxs[i] = um.tjxs(qsrq[i], jsrq[i], unit);
                    else
                        tjxs[i] = "0";
                }

                tjxs[12] = um.tjxs(qsrq[0], sDate, unit);      //本期年统计时间
                tjxs[13] = um.tjxs(qsrqT[0], jsrqT[11], unit); //同期年统计时间

                #endregion

                list = drp.RetArrsRepYearInfo(repName, unit, date, isDay);

                DataTable dtXZ = dr.RetTableXZ("1", repName);

                string[] zb = (string[])list[0];
                string[] un = (string[])list[1];
                string[] lay = (string[])list[2];
                string[] dv = (string[])list[3];
                string[] dvT = (string[])list[4];
                string[] zyB = (string[])list[5];
                string[] zyT = (string[])list[6];
                string[] dvExcel = (string[])list[7];
                string[] dvExcelT = (string[])list[8];

                if (list.Count > 0)
                {
                    #region 显示数据Table

                    if (toExcel == "yes")
                        sb.Append("<table style=\"float: left;\" width=\"110%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX\">");
                    else
                        sb.Append("<table style=\"float: left;\" width=\"110%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" id=\"CX1\">");

                    sb.Append("<tr bgcolor=\"#CFE6FC\">");
                    sb.Append("<td style=\"width=\"10%\" ><div align=\"center\">指 标 名 称</td>");
                    sb.Append("<td style=\"width=\"4%\"><div align=\"center\">单 位 </td>");
                    sb.Append("<td style=\"width=\"4%\"><div align=\"center\">设 计 值</td>");

                    for (int i = 1; i <= 12; i++)
                    {
                        sb.AppendFormat("<td style=\"width:5%\"><div align=\"center\">{0}</td>", i);
                    }

                    sb.Append("<td width=\"5%\" align=\"center\">年度累计</td>");

                    sb.Append("<td width=\"5%\" align=\"center\">本年最优</td>");

                    sb.Append("<td width=\"5%\" align=\"center\">同期累计值</td>");

                    sb.Append("<td width=\"5%\" align=\"center\">同期最优值</td></tr>");

                    for (int i = 1; i < zb.Length; i++)
                    {
                        sb.Append("<tr>");

                        sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                        sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                        sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                        if (dv[i] != null)
                        {
                            if (dv[i].TrimEnd(',').Contains(','))
                            {
                                arr = dv[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {

                                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                    else
                                    {
                                        //本期数据
                                        if (repName == "厂用电报表")
                                        {
                                            if (arr[j] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else if (repName == "综合报表")
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (i <= 10)
                                                { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                                else
                                                {
                                                    if (tjxs[j] == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (tjxs[j] == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                    }
                                }
                            }
                        }

                        //本期最优值
                        if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                        { sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]); }
                        else
                        {
                            if (repName == "厂用电报表")
                            { sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]); }
                            else if (repName == "综合报表")
                            {
                                if (i <= 10)
                                { sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]); }
                                else
                                {
                                    if (tjxs[12] == "0")
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]);
                                }
                            }
                            else
                            {
                                if (tjxs[12] == "0")
                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                else
                                    sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]);
                            }
                        }
                        /////////////////////////////////////////////
                        if (dvT[i] != null)
                        {
                            if (dvT[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvT[i].Split(',');

                                if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                                {
                                    if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                                    {
                                        if (arr[arr.Length - 2] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                }
                                else
                                {
                                    //同期累计
                                    if (repName == "厂用电报表")
                                    {
                                        if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[arr.Length - 2] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                    else if (repName == "综合报表")
                                    {
                                        if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[arr.Length - 2] != null)
                                            {
                                                if (i <= 10)
                                                { sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString()); }
                                                else
                                                {
                                                    if (tjxs[13] == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString());
                                                }
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                    else
                                    {
                                        if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[arr.Length - 2] != null)
                                            {
                                                if (tjxs[13] == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }

                        if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                        {
                            if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                            { sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]); }
                            else
                            {
                                //同期最优值
                                if (repName == "厂用电报表")
                                { sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]); }
                                else if (repName == "综合报表")
                                {
                                    if (i <= 10)
                                    { sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]); }
                                    else
                                    {
                                        if (tjxs[13] == "0")
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]);
                                    }
                                }
                                else
                                {
                                    if (tjxs[13] == "0")
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]);
                                }
                            }
                        }
                        else
                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                    }
                    sb.Append("</table>");

                    #endregion

                    #region 导出ExcelTable
                    if (toExcel == "no")
                        sb.Append("<table style=\"float: left;\" width=\"110%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" style=\"display:none;\" id=\"CX\">");
                    else
                        sb.Append("<table style=\"float: left;\" width=\"110%\" border=\"1\" align=\"center\" class=\"bg\" valign=\"top\" bordercolorlight=\"#999999\" bordercolordark=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"1\" style=\"display:none;\" id=\"CX1\">");

                    sb.Append("<tr bgcolor=\"#CFE6FC\">");
                    sb.Append("<td style=\"width=\"10%\" ><div align=\"center\">指 标 名 称</td>");
                    sb.Append("<td style=\"width=\"4%\"><div align=\"center\">单 位 </td>");
                    sb.Append("<td style=\"width=\"4%\"><div align=\"center\">设 计 值</td>");

                    for (int i = 1; i <= 12; i++)
                    {
                        sb.AppendFormat("<td style=\"width:5%\"><div align=\"center\">{0}</td>", i);
                    }

                    sb.Append("<td width=\"5%\" align=\"center\">年度累计</td>");

                    sb.Append("<td width=\"5%\" align=\"center\">本年最优</td>");

                    sb.Append("<td width=\"5%\" align=\"center\">同期累计值</td>");

                    sb.Append("<td width=\"5%\" align=\"center\">同期最优值</td></tr>");

                    for (int i = 1; i < zb.Length; i++)
                    {
                        sb.Append("<tr>");

                        sb.AppendFormat("<td align='center'>{0}</td>", zb[i]);

                        sb.AppendFormat("<td align='center'>{0}</td>", un[i]);

                        sb.AppendFormat("<td align='center'>{0}</td>", lay[i]);

                        if (dvExcel[i] != null)
                        {
                            if (dvExcel[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvExcel[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {

                                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                                    {
                                        if (arr[j] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                    else
                                    {
                                        //本期数据
                                        if (repName == "厂用电报表")
                                        {
                                            if (arr[j] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else if (repName == "综合报表")
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (i <= 10)
                                                { sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString()); }
                                                else
                                                {
                                                    if (tjxs[j] == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                                }
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                        {
                                            if (arr[j] != null)
                                            {
                                                if (tjxs[j] == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[j].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                    }
                                }
                            }
                        }

                        //本期最优值
                        if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                        { sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]); }
                        else
                        {
                            if (repName == "厂用电报表")
                            { sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]); }
                            else if (repName == "综合报表")
                            {
                                if (i <= 10)
                                { sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]); }
                                else
                                {
                                    if (tjxs[12] == "0")
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]);
                                }
                            }
                            else
                            {
                                if (tjxs[12] == "0")
                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                else
                                    sb.AppendFormat("<td align='center'>{0}</td>", zyB[i]);
                            }
                        }
                        /////////////////////////////////////////////
                        if (dvExcelT[i] != null)
                        {
                            if (dvExcelT[i].TrimEnd(',').Contains(','))
                            {
                                arr = dvExcelT[i].Split(',');

                                if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                                {
                                    if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                                    {
                                        if (arr[arr.Length - 2] != null)
                                            sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString());
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                    }
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                }
                                else
                                {
                                    //同期累计
                                    if (repName == "厂用电报表")
                                    {
                                        if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[arr.Length - 2] != null)
                                                sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString());
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                    else if (repName == "综合报表")
                                    {
                                        if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[arr.Length - 2] != null)
                                            {
                                                if (i <= 10)
                                                { sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString()); }
                                                else
                                                {
                                                    if (tjxs[13] == "0")
                                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                    else
                                                        sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString());
                                                }
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                    else
                                    {
                                        if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                                        {
                                            if (arr[arr.Length - 2] != null)
                                            {
                                                if (tjxs[13] == "0")
                                                    sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                                else
                                                    sb.AppendFormat("<td align='center'>{0}</td>", arr[arr.Length - 2].ToString());
                                            }
                                            else
                                                sb.AppendFormat("<td align='center'>{0}</td>", "&nbsp;");
                                        }
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                                    }
                                }
                            }
                        }

                        if (Convert.ToDateTime(jsrqT[11]) > Convert.ToDateTime(xzTime))
                        {
                            if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "累计" || dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                            { sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]); }
                            else
                            {
                                //同期最优值
                                if (repName == "厂用电报表")
                                { sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]); }
                                else if (repName == "综合报表")
                                {
                                    if (i <= 10)
                                    { sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]); }
                                    else
                                    {
                                        if (tjxs[13] == "0")
                                            sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                        else
                                            sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]);
                                    }
                                }
                                else
                                {
                                    if (tjxs[13] == "0")
                                        sb.AppendFormat("<td align='center'>{0}</td>", "0");
                                    else
                                        sb.AppendFormat("<td align='center'>{0}</td>", zyT[i]);
                                }
                            }
                        }
                        else
                            sb.AppendFormat("<td align='center'>{0}</td>", "0"); //
                    }
                    sb.Append("</table>");
                    #endregion
                }
            }
            else
            {
                sb.AppendFormat("<td colspan=\"19\"  align='center'>{0}</td>", "对不起,请选择正确日期然后进行查询...");
                return sb.ToString();
            }

            return sb.ToString();
        }

        /// <summary>
        /// 日期判断
        /// </summary>
        private string IsQuarTerly(DateTime date, int jd, out bool isDay, out string errMsg)
        {
            string qsrqB = "";
            string jsrqB = "";
            string qsrqT = "";
            string jsrqT = "";

            isDay = false;
            errMsg = "";

            DateTime ndate = DateTime.Now;

            if (date.Year < ndate.Year)
            {
                #region  历史年份
                if (jd == 1)
                {
                    qsrqB = date.Year + "-01-01 00:00:00";
                    jsrqB = date.Year + "-04-01 00:00:00";

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(jsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");

                }
                else if (jd == 2)
                {
                    qsrqB = date.Year + "-04-01 00:00:00";
                    jsrqB = date.Year + "-07-01 00:00:00";

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(jsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");

                }
                else if (jd == 3)
                {
                    qsrqB = date.Year + "-07-01 00:00:00";
                    jsrqB = date.Year + "-10-01 00:00:00";

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(jsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");

                }
                else
                {
                    qsrqB = date.Year + "-10-01 00:00:00";
                    jsrqB = DateTime.Parse(date.Year + "-12-31 00:00:00").AddDays(1).ToString("yyyy-MM-dd H:mm:ss");

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(jsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");

                }
                #endregion
            }
            else if (date.Year == ndate.Year)
            {
                if (jd == 1)
                {
                    qsrqB = date.Year + "-01-01 00:00:00";
                    jsrqB = date.Year + "-04-01 00:00:00";

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(jsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                }
                else if (jd == 2)
                {
                    qsrqB = date.Year + "-04-01 00:00:00";
                    jsrqB = date.Year + "-07-01 00:00:00";

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(jsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                }
                else if (jd == 3)
                {
                    qsrqB = date.Year + "-07-01 00:00:00";
                    jsrqB = date.Year + "-10-01 00:00:00";

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(jsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                }
                else
                {
                    qsrqB = date.Year + "-10-01 00:00:00";
                    jsrqB = DateTime.Parse(date.Year + "-12-31 00:00:00").AddDays(1).ToString("yyyy-MM-dd H:mm:ss");

                    qsrqT = DateTime.Parse(qsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                    jsrqT = DateTime.Parse(jsrqB).AddYears(-1).ToString("yyyy-MM-dd H:mm:ss");
                }

                if (ndate >= DateTime.Parse(qsrqB) && ndate < DateTime.Parse(jsrqB))
                {
                    //jsrqB = ndate.AddHours(-1).ToString("yyyy-MM-dd H:00:00");
                    jsrqB = ndate.ToString("yyyy-MM-dd 0:00:00");
                    isDay = true;
                }
                else if (ndate < DateTime.Parse(qsrqB))
                {
                    errMsg = "请重新选择时间进行查询...";
                }
            }
            else { errMsg = "请重新选择时间进行查询..."; }

            return qsrqB + ";" + jsrqB + ";" + qsrqT + ";" + jsrqT;
        }


        #region 中电芜湖电厂内部发送数据

        /// <summary>
        /// 日报(机组轮转)
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <returns></returns>
        public DataTable RetTableByDayToMySql(string repName, string repType, DateTime date)
        {
            string[] arr;
            string qsrq;
            string jsrq;
            string tjxsA;
            string tjxsB;

            bool isTure = false;

            DateTime dtNow = DateTime.Now;
            DataTable dt = new DataTable();

            if (date < dtNow && date >= Convert.ToDateTime(xzTime))
            {
                if (dtNow.Year == date.Year && dtNow.Month == date.Month && dtNow.Day == date.Day)
                {
                    qsrq = date.ToString("yyyy-MM-dd 00:00:00");
                    jsrq = dtNow.AddHours(-1).ToString("yyyy-MM-dd H:00:00");
                    isTure = true;
                }
                else
                {
                    qsrq = date.ToString("yyyy-MM-dd H:mm:ss");
                    jsrq = date.AddDays(+1).ToString("yyyy-MM-dd H:mm:ss");
                }
            }
            else
            { sb.Append("请输入正确的日期进行查询......"); return null; }

            if (repType == "日报")
            { repType = "日点"; }

            tjxsA = um.tjxs(qsrq, jsrq, 1);
            tjxsB = um.tjxs(qsrq, jsrq, 2);

            list = dr.RetArrsRepDay(repName, repType, qsrq, jsrq, isTure);

            DataTable dtXZ = dr.RetTableXZ("1", repName);

            string[] zb = (string[])list[0];
            string[] un = (string[])list[1];
            string[] lay = (string[])list[2];
            string[] dv = (string[])list[3];
            string[] dvExcel = (string[])list[4];

            if (list.Count > 0)
            {
                dt.Columns.Add("指标名称", typeof(string));
                dt.Columns.Add("单位", typeof(string));
                dt.Columns.Add("设计值", typeof(string));
                dt.Columns.Add("#1号机组", typeof(string));
                dt.Columns.Add("#2号机组", typeof(string));
                dt.Columns.Add("全厂", typeof(string));
                dt.Columns.Add("写入时间", typeof(string));

                for (int i = 1; i < zb.Length; i++)
                {
                    DataRow dw = dt.NewRow();

                    dw[0] = zb[i];
                    dw[1] = un[i];
                    dw[2] = lay[i];

                    if (dtXZ.Rows[i - 1]["参数类型"].ToString() == "电量")
                    {
                        if (dv[i] != null)
                        {
                            if (dv[i].TrimEnd(',').Contains(','))
                            {
                                arr = dv[i].Split(',');

                                for (int j = 0; j < arr.Length - 1; j++)
                                {
                                    if (arr[j] != null)
                                        dw[j + 3] = arr[j].ToString();
                                    else
                                        dw[j + 3] = "";
                                }
                            }
                        }
                    }
                    else
                    {
                        if (repName == "厂用电报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (zb[i] == "输煤单耗" || zb[i] == "输煤设备电率")
                                        { dw[j + 3] = "0"; }
                                        else
                                        {
                                            if (arr[j] != null)
                                                dw[j + 3] = arr[j].ToString();
                                            else
                                                dw[j + 3] = "";
                                        }
                                    }
                                }
                            }
                        }
                        else if (repName == "汽机报表" || repName == "锅炉报表")
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (j == 0)
                                            {
                                                if (tjxsA == "0")
                                                    dw[j + 3] = "0";
                                                else
                                                    dw[j + 3] = arr[j].ToString();
                                            }
                                            else if (j == 1)
                                            {
                                                if (tjxsB == "0")
                                                    dw[j + 3] = "0";
                                                else
                                                    dw[j + 3] = arr[j].ToString();
                                            }
                                            else
                                                dw[j + 3] = arr[j].ToString();
                                        }
                                        else
                                            dw[j + 3] = "";
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (dv[i] != null)
                            {
                                if (dv[i].TrimEnd(',').Contains(','))
                                {
                                    arr = dv[i].Split(',');

                                    for (int j = 0; j < arr.Length - 1; j++)
                                    {
                                        if (arr[j] != null)
                                        {
                                            if (i <= 10)
                                            { dw[j + 3] = arr[j].ToString(); }
                                            else
                                            {
                                                if (j == 0)
                                                {
                                                    if (tjxsA == "0")
                                                        dw[j + 3] = "0";
                                                    else
                                                        dw[j + 3] = arr[j].ToString();
                                                }
                                                else if (j == 1)
                                                {
                                                    if (tjxsB == "0")
                                                        dw[j + 3] = "0";
                                                    else
                                                        dw[j + 3] = arr[j].ToString();
                                                }
                                                else
                                                    dw[j + 3] = arr[j].ToString();
                                            }
                                        }
                                        else
                                            dw[j + 3] = "";
                                    }
                                }
                            }
                        }
                    }

                    dw[6] = qsrq;

                    dt.Rows.Add(dw);
                }
            }

            return dt;
        }

        #endregion

        public string test()
        {

            return Environment.CurrentDirectory + ":" + System.Web.HttpContext.Current.Request.PhysicalApplicationPath;
        }
    }
}
